{% extends "_base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block scripts %}
    {{super()}}
    <script type="application/javascript">
        function usetiame(){
                $("#parent_id").val(
                        function(){
                            return $.map($('#table').bootstrapTable('getSelections'), function(row) {
                                return row.node_id
                            });
                        });
            }
    </script>
{% endblock %}
{% block insidedContent %}
    {% for message in get_flashed_messages() %}
    <div class="alert alert-warning">
        <button type="button" class="close" data-dismiss="alert">×</button>
        {{ message }}
    {% endfor %}
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-offset-3 col-lg-6 col-md-offset-3 col-md-6 col-sm-12 col-xs-12">

                <form class="form form-horizontal"  method="POST"  role="form">
                    {{ form.hidden_tag() }}

                    {{ wtf.form_errors(form, hiddens="only") }}
                    {{ wtf.form_field(form.node_id) }}
                    {{ wtf.form_field(form.dept_name) }}
                    {{ wtf.form_field(form.sys_id) }}

                    {{ form.parent_id.label( class="form-group") }}
                    <div class="input-group form-group  required">
                      {{ form.parent_id(class="form-control")}}
                      <span class="input-group-btn">
                        <button class="btn btn-default btn-primary" type="button" data-toggle="modal" data-target="#myModal">选择</button>
                      </span>
                    </div><!-- /input-group -->
                    {{ wtf.form_field(form.submit) }}
                </form>
            </div>
        </div>
    </div>
    <!-- 模态框（Modal） -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                </div>
                <div class="modal-body">
{#                    <iframe name="childFrame" id="childFrame"  align="center" width="550" src='{{ url_for('list') }}' frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>#}
                    <table id="table" data-toggle="table" data-toolbar="#toolbar" data-height="150" data-click-to-select="true" data-url="{{ url_for("Depoutjson") }}">
                        <thead>
                        <tr>
                            <th data-field="state" data-radio="true"></th>
                            <th data-field="node_id">部门内码</th>
                            <th data-field="dept_name">部门名称</th>
                            <th data-field="sys_id">部门系统编码</th>
                            <th data-field="parent_id">上级内码</th>
                        </tr>
                        </thead>
                    </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"> 关闭 </button>
                    <button type="button" class="btn btn-primary" id="submitID" onclick="usetiame()" data-dismiss="modal"> 确定 </button>
                </div>

            </div><!-- /.modal-content -->
        </div><!-- /.modal -->

    </div>
{% endblock %}
